

//------------Formatting--------------//
clear all
/* Sets Latex fonts for outputting graphs for paper */
/* Switch to Sans if outputting for presentations */
*graph set window fontfacesans   "LM Sans 12"
graph set window fontface   "LM Roman 10"
*graph set window fontfaceserif  "LM Roman 10"
*graph set svg fontfacesans   "LM Sans 12"
graph set svg fontface   "LM Roman 10"
*graph set svg fontfaceserif  "LM Roman 10"
//* When outputting, "graph export "NAME.svg", replace as(svg)"
/* Sets a simple mono scheme */
/* Should still be able to specify colors in a graph command */
set scheme s1mono

	//Feb 2025
	use "$data/3_decision_makers/DM_Parent_Survey_Jan2025_clean.dta", clear
	
//Figure 5
	//Which male vs. female comparisons are signficant
	global LabMatVars "LabMat01_CareerTrajectory LabMat02_FlexiblibleJob LabMat03_LowerPay LabMat04_ShortCommute LabMat05_StayAtHome LabMat06_DiffMajor LabMat07_LessPromotion LabMat08_DifficultFocus LabMat09_WorseEmployee LabMat10_NegHealth LabMat11_NegPartnerRel"		
	foreach var in $LabMatVars {
	ttest `var', by(HH_MotherRespond)
	reg `var' HH_MotherRespond, robust
	estimates store `var'	
	}	
		
	esttab 	LabMat01_CareerTrajectory LabMat02_FlexiblibleJob LabMat03_LowerPay LabMat04_ShortCommute LabMat05_StayAtHome LabMat06_DiffMajor LabMat07_LessPromotion
	esttab  LabMat08_DifficultFocus LabMat09_WorseEmployee LabMat10_NegHealth LabMat11_NegPartnerRel
	
	//Non-signficant ones
	ttest LabMat01_CareerTrajectory, by(HH_MotherRespond)	
	ttest LabMat06_DiffMajor, by(HH_MotherRespond)		
	ttest LabMat11_NegPartnerRel, by(HH_MotherRespond)	//significant if one way t-test
	
	
sort HH_MotherRespond ResponseId	
bysort HH_MotherRespond : gen running=_n

gen LabMatAll=.
gen LabMatAllhi=.
gen LabMatAlllow=.


local i 1
foreach var in $LabMatVars {	
gen mean`var'=.
gen SD`var'=.
gen N`var'=.
summarize `var'  if HH_MotherRespond == 1, detail
	replace mean`var'=r(mean) if HH_MotherRespond == 1
	replace SD`var'=r(sd) if HH_MotherRespond == 1
	replace N`var'=r(N) if HH_MotherRespond == 1
summarize `var'  if HH_MotherRespond == 0, detail
	replace mean`var'=r(mean) if HH_MotherRespond == 0
	replace SD`var'=r(sd) if HH_MotherRespond == 0
	replace N`var'=r(N) if HH_MotherRespond == 0	
//bysort 	HH_MotherRespond: egen mean`var'= mean(`var') 
//bysort 	HH_MotherRespond: egen SD`var'= sd(`var') 
//bysort 	HH_MotherRespond: egen N`var'= count(`var') 

generate hi`var' = mean`var' + invttail(N`var'-1,0.025)*(SD`var' / sqrt(N`var'))
generate low`var' = mean`var' - invttail(N`var'-1,0.025)*(SD`var' / sqrt(N`var')) 

replace LabMatAll=mean`var' if HH_MotherRespond==0&running==`i'
replace LabMatAll=mean`var' if HH_MotherRespond==1&running==`i'

replace LabMatAllhi=hi`var' if HH_MotherRespond==0&running==`i'
replace LabMatAllhi=hi`var' if HH_MotherRespond==1&running==`i'

replace LabMatAlllow=low`var' if HH_MotherRespond==0&running==`i'
replace LabMatAlllow=low`var' if HH_MotherRespond==1&running==`i'

display `i'
local i=`i'+ 1
}

tabstat LabMatAll if HH_MotherRespond==1&running<=11 [aw=a_weight], by(running)
tabstat LabMatAll if HH_MotherRespond==0&running<=11 [aw=a_weight], by(running)


gen Question=.
	replace Question=1 if HH_MotherRespond==0&running==2
	replace Question=2 if HH_MotherRespond==1&running==2
	
	replace Question=4 if HH_MotherRespond==0&running==4
	replace Question=5 if HH_MotherRespond==1&running==4
	
	replace Question=7 if HH_MotherRespond==0&running==5
	replace Question=8 if HH_MotherRespond==1&running==5
	
	replace Question=10 if HH_MotherRespond==0&running==3
	replace Question=11 if HH_MotherRespond==1&running==3
	
	replace Question=13 if HH_MotherRespond==0&running==8
	replace Question=14 if HH_MotherRespond==1&running==8
	
	replace Question=16 if HH_MotherRespond==0&running==1
	replace Question=17 if HH_MotherRespond==1&running==1
	
	replace Question=19 if HH_MotherRespond==0&running==7
	replace Question=20 if HH_MotherRespond==1&running==7
	
	replace Question=22 if HH_MotherRespond==0&running==11
	replace Question=23 if HH_MotherRespond==1&running==11
	
	replace Question=25 if HH_MotherRespond==0&running==10
	replace Question=26 if HH_MotherRespond==1&running==10
	
	replace Question=28 if HH_MotherRespond==0&running==9
	replace Question=29 if HH_MotherRespond==1&running==9
	
	replace Question=31 if HH_MotherRespond==0&running==6
	replace Question=32 if HH_MotherRespond==1&running==6
	
	
label define Questionl ///
					1 "more flexibility" ///
					4 "shorter commute" ///
					7 "stay-at-home parent"	///
					10  "lower pay"	///
					13 "difficult to focus"	///
					16 "neg impacted my career trajectory" ///
					19 "less likely promoted"	///
					22 "neg effect partner relationship" ///
					25 "neg effect health"	///
					28  "worse employee" ///
					31 "different college major"	
label values Question Questionl	
	
	/*
	//Graph with signficance 
	twoway 	(bar  LabMatAll Question if HH_MotherRespond==1&running<=11, bcolor(orange) sort(LabMatAll)) ///
			(bar  LabMatAll Question if HH_MotherRespond==0&running<=11, bcolor(ltblue)) ///			
			(rcap LabMatAllhi LabMatAlllow Question if HH_MotherRespond==0&running<=11, lcolor(black))  /// 
			(rcap LabMatAllhi LabMatAlllow Question if HH_MotherRespond==1&running<=12, lcolor(black)) ///
				, text(.75 1.5 "***",  ) /// LabMat02_FlexiblibleJob Pr(T < t) = 0.0000
				text(.7 4.5 "***",  ) /// LabMat04_ShortCommute Pr(T < t) = 0.0000
				text(.52 7.5 "***",  ) /// LabMat05_StayAtHome Pr(T < t) = 0.0000
				text(.5 10.5 "***",  ) /// LabMat03_LowerPay Pr(T < t) = 0.0000
				text(.4 13.5 "***",  ) /// LabMat08_DifficultFocus Pr(T < t) = 0.0007
				text(.35 16.5 "  ",  ) /// LabMat01_CareerTrajectory  Pr(T < t) = 0.1697
				text(.4 19.5 "***",  ) /// LabMat07_LessPromotion Pr(T < t) = 0.0008
				text(.35 22.5 "+",  ) /// LabMat11_NegPartnerRel Pr(T < t) = 0.0704
				text(.32 25.5 "**",  ) /// LabMat10_NegHealth Pr(T < t) = 0.0046
				text(.32 28.5 "**",  ) /// LabMat09_WorseEmployee Pr(T < t) = 0.0050
				text(.15 31.5 " ",  ) /// LabMat06_DiffMajor Pr(T < t) = 0.1840	
				xlabel(1 4 7 10 13 16 19 22 25 28 31 , valuelabe angle(60)) ///
			ytitle("Strongly agree/Agree") ///
		legend( order(  1 "Mother" 2 "Father") )
	graph export "$output/LaborMarketSurvey_v3.png", as(png) name("Graph")	replace		
	*/
	
cd "$output"	
//In code below one has to replace values of 100 with 99 or the histogram x-axis sometimes goes to 150
foreach var in $OrgVars2{
 	replace Dec24S_`var'_Me=99 if Dec24S_`var'_Me==100
 	qui histogram Dec24S_`var'_Me, by(HH_MotherRespond) fraction xline(50, lwidth(5pt) lcolo(red)) yscale(range(0(.2) .8)) xscale(range(0 100)) saving("$output/figures/temp/`var'.gph", replace)
 	qui histogram Dec24S_`var'_Me if OrgProportionMe>=40&OrgProportionMe<=60, by(HH_MotherRespond) fraction xline(50, lwidth(5pt) lcolo(red)) yscale(range(0(.2) .8)) xscale(range(0 100)) saving("$output/figures/temp/`var'_40_60pct.gph", replace)

 	replace Dec24S_`var'_Me=100 if Dec24S_`var'_Me==99
 }	
 
sum Dec24S_*

sum Dec24S_* if OrgProportionMe>=40&OrgProportionMe<=60


//40 to 60 respondents			

graph combine "$output/figures/temp/SportsProportion_40_60pct.gph" "$output/figures/temp/TutoringProportion_40_60pct.gph" "$output/figures/temp/MedDentalProportion_40_60pct.gph" "$output/figures/temp/ExtraNSportProportion_40_60pct.gph" "$output/figures/temp/SchoolProportion_40_60pct.gph" "$output/figures/temp/ChildcareProportion_40_60pct.gph" "$output/figures/temp/ReligiousProportion_40_60pct.gph" "$output/figures/temp/LawEnforceProportion_40_60pct.gph" "$output/figures/temp/ExtendedFamProportion_40_60pct.gph", row(3) ycommon imargin(0 0 0 0) 
	graph export "$output/figures/Figure_M1.png", as(png) name("Graph")	replace
	
graph combine "$output/figures/temp/SportsProportion.gph" "$output/figures/temp/TutoringProportion.gph" "$output/figures/temp/MedDentalProportion.gph" "$output/figures/temp/ExtraNSportProportion.gph" "$output/figures/temp/SchoolProportion.gph" "$output/figures/temp/ChildcareProportion.gph" "$output/figures/temp/ReligiousProportion.gph" "$output/figures/temp/LawEnforceProportion.gph" "$output/figures/temp/ExtendedFamProportion.gph", row(3) ycommon imargin(0 0 0 0)	
	graph export "$output/figures/Figure_M2.png", as(png) name("Graph")	replace	

		